Overview

To save on boilerplate code, and improve navigatability in the ide, maestro provides wrappers that allow for easy creation of observers, which take function pointers, instead of strings, and will automatically call back with the node, value, node and value, or nothing, depending the sendMode

Delaying execution

Tasks

Observers

Value Observing

Many times we want to observe a specific value on an observer, to achieve this we use the ValueObserver utility class. This class allows us to execute code, when a certain value comparator condition is met. A value comparator can be:

The ValueObserver takes a constructor of:

To add observers, invoke onValue, with the target value, callback function and comparator:

e.g.

    function onFraction(fraction, func, scope)
      if m.fractionValueObserver = invalid
        m.fractionValueObserver = new mc.tasks.ValueObserver(m.interpolator, "fraction", scope)
      end if
      m.fractionValueObserver.onValue(fraction, func, ">=")
    end function

Delayed tasks

As a convenience, you can create a DelayedTaskManager which makes it trivial to do things like schedule a refresh token task.

Use the functions

Example use:

In your ioc setup:

      delayedTaskManager = m.createSGNode("mc_delayedTaskManager", invalid, "delayedTaskManager")
      m.setInstance("delayedTaskManager", delayedTaskManager)

Then, when scheduling refreshing an auth token, with an AuthTask, something like:

    @inject("delayedTaskManager")
    private delayedTaskManager as mc.types.node

    protected function setRefreshTimer()
      delayedTaskManager@.scheduleDelayedTask("AuthTask", "refreshTask", 300, { "command": "refresh" })
    end function